<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class About extends Model
{
    protected $fillable = [
        'meta_key',
        'meta_value',
        'type',
    ];

    const TYPE_ABOUT = 1; // 关于我们
    const TYPE_OFFLINE = 2; // 线下转账
    const TYPE_SITE = 3; // 基础信息

    public static function set($type, $key, $value)
    {
        return static::firstOrCreate([
            'meta_key' => $key,
            'type' => $type,
        ], [
            'meta_value' => '',
        ])->update([
            'meta_value' => (string)$value
        ]);
    }
}
